package com.pi.reservaCita2.controler;


import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.*;

public class loginHandler extends Composite implements ClickHandler  {
	//private FlowPanel fp = new FlowPanel();

	private Button addStockButton; 
	private TextBox newSymbolTextBox;
	public loginHandler() 
	{  addStockButton= new Button("Boton x");
		newSymbolTextBox = new TextBox();
		//initWidget(fp);
	    //fp.add(addStockButton);
	    //fp.add(newSymbolTextBox);
		addStockButton.addClickHandler(this);
	}

	public void addStock()
	{
		final String symbol = newSymbolTextBox.getText().toUpperCase().trim();
	    newSymbolTextBox.setFocus(true);

	    // Stock code must be between 1 and 10 chars that are numbers, letters, or dots.
	    if (!symbol.matches("^[0-9A-Z\\.]{1,10}$")) {
	      Window.alert("'" + symbol + "' no es permitido.");
	      newSymbolTextBox.selectAll();
	      return;
	    }

		newSymbolTextBox.setText("");
	}
	@Override
	public void onClick(ClickEvent event) {
		// TODO Auto-generated method stub
		 Widget sender = (Widget) event.getSource();

		    if (sender == addStockButton) {
		      // handle b1 being clicked
		    	addStock();
		    } 

		
	}
	public Button getAddStock()
	{		
		return addStockButton;
	}
	public TextBox getnewSymbol()
	{
		return newSymbolTextBox;
	}
	
	

	
	
	
	

}
